package com.longyiqun.cm.controller.scene;

import com.longyiqun.cm.PageUtil;
import com.longyiqun.cm.domain.SceneEntity;
import com.longyiqun.cm.mapper.SceneMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/scene")
public class SceneControllerImpl implements SceneController{


    @Autowired
    PageUtil pageUtil;
    @Autowired
    SceneMapper sceneMapper;
    @Override
    @RequestMapping("/addScene")
    public String addScene(Model model){
        return "Scene/addScene";
    }
    @Override
    @RequestMapping("/sceneList")
    public String SceneList(Model model){
        return "Scene/sceneList";
    }

    @Override
    @RequestMapping("/SceneDetail")
    public String Scenedetail(@Param("sceneID")String sceneID, Model model){
        String sql = "select * from test_scene_entity where sceneID = "+sceneID;
        SceneEntity tc =  sceneMapper.findOne(sql);
        model.addAttribute("tc", tc);
        return "Scene/sceneDetail";
    }

    @Override
    @RequestMapping("/APIList")
    public String APIList(@Param("sceneID")String sceneID, Model model){
        model.addAttribute("sceneID", sceneID);
        return "Scene/ApiList";
    }

    @Override
    @RequestMapping("/addAPI")
    public String addAPI(@Param("sceneID")String sceneID,Model model){
        model.addAttribute("sceneID", sceneID);
        return "Scene/addAPI";
    }

    @Override
    @RequestMapping("/APIDetail")
    public String APIDetail(@Param("relationID")String relationID, Model model){
        String sql = "select * from test_api_entity where relationID = "+relationID;
        SceneEntity tc =  sceneMapper.findOne(sql);
        model.addAttribute("tc", tc);
        System.out.println(tc.getUrl());
        return "Scene/ApiDetail";
    }
}
